package com.moter.one.wyydemo1.controller;

import com.moter.one.wyydemo1.backstage.vo.DataVo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
public class IndexController {

    //跳转首页
    @RequestMapping("/index")
    public String index(){
        return "index";
    }

    //跳转登录页面
    @RequestMapping("/login")
    public String admin(){
        return "login";
    }

    //后台管理登陆
    @ResponseBody
    @RequestMapping("/adminLogin")
    public DataVo<String> login(String username, String password, HttpSession session){
        session.setAttribute("username", username);
//      FIXME(
//       此处业务逻辑有问题
//       config异常处理
//       框架底层逻辑不熟
//       )
//      TODO()

        DataVo<String> dataVo = new DataVo<>(0, "登录成功");
        System.out.println(dataVo);
        return dataVo;
    }

    //后台管理首页
    @RequestMapping("/backStage")
    public String backStage(){
        return "backStage";
    }

    @RequestMapping("/axios")
    public String axios(){
        return "practice_axios";
    }

    //测试elementUI
    @RequestMapping("/element")
    public String element(){
        return "search";
    }
//    前端测试
    @RequestMapping("/test")
    public String test(){
        return "practice_axios";
    }
}
